package com.moli.iov.down.command.design.strategy.commandreqdto.impl;

import com.moli.iov.down.enums.command.CommandEnum;
import com.moli.iov.down.enums.OperateTypeEnum;
import com.moli.iov.down.enums.command.RemoteControlEnum;
import com.moli.iov.down.enums.command.extend.ExtendKeyEnum;
import com.moli.iov.down.model.dto.remoting.CommandDto;
import com.moli.iov.down.model.dto.remoting.CommandReqDto;
import com.moli.iov.down.command.design.strategy.commandreqdto.CommandReqDtoStrategy;

/**
 * <p>
 *  钥匙使能、钥匙禁用
 * </p>
 *
 * @author: zql
 * @Date: 2018/12/28 11:53
 */
public class KeyEnableDisabledStrategy implements CommandReqDtoStrategy {

    @Override
    public CommandDto make(CommandReqDto commandReqDto) {

        CommandDto commandDto = new CommandDto();
        commandDto.setVin(commandReqDto.getVin());
        commandDto.setIsRetry(commandReqDto.getIsRetry());

        commandDto.setCommand(CommandEnum.REMOTE_CONTROL.getFlag());
        commandDto.setControlCommand(RemoteControlEnum.KEY_CONTROL.getFlag());
        commandDto.setControlContent(commandReqDto.getOperateType() == OperateTypeEnum.KEY_ENABLE.getFlag() ?
                ExtendKeyEnum.ENABLE.getFlag() : ExtendKeyEnum.DISABLED.getFlag());

        return commandDto;
    }
}
